//////////////////////////////////////////////////////////////////////////////////
//                                                                              //
//  This file is part of the buola project (https://code.google.com/p/buola/).  //
//                                                                              //
//  Copyright(c) 2007-2012 Xavi Gratal                                          //
//  gratal AT gmail DOT com                                                     //
//                                                                              //
//  Buola is free software: you can redistribute it and/or modify               //
//  it under the terms of the GNU General Public License as published by        //
//  the Free Software Foundation, either version 3 of the License, or           //
//  (at your option) any later version.                                         //
//                                                                              //
//  Buola is distributed in the hope that it will be useful,                    //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of              //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               //
//  GNU General Public License for more details.                                //
//                                                                              //
//  You should have received a copy of the GNU General Public License           //
//  along with buola.  If not, see <http://www.gnu.org/licenses/>.              //
//                                                                              //
//////////////////////////////////////////////////////////////////////////////////

#include <buola/buola.h>

#include <buola/io/cfile.h>
#include <buola/io/curischeme.h>
#include <buola/os/cmimetype.h>
#include <buola/io/cfolder.h>

#include <fcntl.h>
#include <sys/ioctl.h>

namespace buola { namespace io {

///////////////////////////// Misc ////////////////////////////////
/*
bool CFile::SSorter::operator()(const PFile &p1,const PFile &p2)
{
    long int lRet=0;

    if(mSortBy&SORT_TIME)
    {
        lRet=(p1->GetMTime()-p2->GetMTime()).count();
    }
    else if(mSortBy&SORT_SIZE)
    {
        lRet=p1->mSize-p2->mSize;
    }
    else if(mSortBy&SORT_NAME)
    {
        if(mSortBy&SORT_CASESENSITIVE)
            lRet=p1->mURL.GetName().compare(p2->mURL.GetName());
        else
            lRet=tolower_clone(p1->mURL.GetName()).compare(tolower_clone(p2->mURL.GetName()));
    }

    if(mSortBy&SORT_REVERSE)
    {
        lRet=-lRet;
    }

    if(mSortBy&SORT_DIRSFIRST)
    {
        if(p1->IsFolder())
        {
            if(!p2->IsFolder())
            {
                lRet=-1;
            }
        }
        else
        {
            if(p2->IsFolder())
            {
                lRet=1;
            }
        }
    }

    if(lRet==0)
    {
        if(mSortBy&SORT_CASESENSITIVE)
            lRet=p1->mURL.GetName().compare(p2->mURL.GetName());
        else
            lRet=tolower_clone(p1->mURL.GetName()).compare(tolower_clone(p2->mURL.GetName()));
    }

    return (lRet<0);
}
*/
/////////////////////// Setting the path ///////////////////////////

CFile::CFile(const CURI &pURI)
    :   mImpl(pURI.Scheme()->GetFileImpl(pURI))
{}

CFile::~CFile()
{}

void CFile::Refresh()
{
}

CURI CFile::GetCanonicalURI() const
{
    return URI();
}

CFolder CFile::GetParent() const
{
//    return GetImpl()->GetParent();
    return CFolder(URI());
}

/*namespace io*/ } /*namespace buola*/ }
